Ext.ns("main");

Ext.setup({
	icon: 'icon.png',
	glossOnIcon: false,
	tabletStartupScreen: 'tablet_startup.png',
	phoneStartupScreen: 'phone_startup.png',
	onReady: function() {
		main.init();
		addrSearch.init();
		main.MainPanel.layout.setActiveItem( addrSearch.list_panel );
	}
});

main.init = function() {
	// 패널들의 상태 기록.
	main.isExistAddrPanel = false;
	
	// 메인패널을 만든다.
	_makeMainPanel();
	// 모델을 등록한다.
	_makeModels();
};

var bottom = {
	addrSearchBtn : {
		cls :'addrSearchBtn',
		iconMask: true,
		iconAlign: 'top',
		iconCls: 'address_book',
		text: '주소검색',
		handler: function(btn,event) {
			addrSearch.init();
			main.MainPanel.layout.setActiveItem( addrSearch.panel1 );
		}
	},
	
	nameSearchBtn : {
		cls: 'nameSearchBtn',
		iconMask: true,
		iconAlign: 'top',
		iconCls: 'search',
		text: '이름검색',
		handler: function(btn,event) {
			nameSearch.init();
			main.MainPanel.layout.setActiveItem( nameSearch.panel1 );
		}
	},
	
	aroundSearchBtn : {
		cls: 'aroundSearchBtn',
		iconMask: true,
		iconAlign: 'top',
		iconCls: 'locate',
		text: '주변검색',
		handler: function(btn,event) {
			aroundSearch.init();
			main.MainPanel.layout.setActiveItem( aroundSearch.panel1 );
		}		
	},
	
	favoriteBtn : {
		cls: 'favoriteBtn',
		iconMask: true,
		iconAlign: 'top',
		iconCls: 'favorites',
		text: '즐겨찾기',
		handler: function(btn,event) {
			favorite.init();
			main.MainPanel.layout.setActiveItem( favorite.panel1 );
		}
	},
	
	settingBtn : {
		cls: 'settingBtn',
		iconMask: true,
		iconAlign: 'top',
		iconCls: 'settings',
		text: '설정',
		handler: function(btn,event) {
			setting.init();
			main.MainPanel.layout.setActiveItem( setting.panel1 );
		}
	}
};
var bottomPanel = {
		dock: 'bottom',
		xtype: 'toolbar',
		layout: {
			type: 'hbox',
			align: 'center',
			pack: 'center'
		},
		items: [
		        bottom.addrSearchBtn , 
		        bottom.nameSearchBtn , 
		        bottom.aroundSearchBtn , 
		        bottom.favoriteBtn , 
		        bottom.settingBtn ]
};

main.isAddrSearch = function() {
	return main.isExistAddrPanel;
};

main.setAddrSearch = function() {
	main.isExistAddrPanel = true;
};

_makeMainPanel = function() {
	main.MainPanel = new Ext.Panel({
		fullscreen: true,
		id: 'MainPanel',
		
		cardSwitchAnimation:"slide",
		layout:'card',
		
		dockedItems:[ bottomPanel ]	
	});
};

_makeModels = function() {
	Ext.regModel('carc_info' , {
		fields: [
		         'name'
		         ]
	});
};
_makeModels2 = function() {
	Ext.regModel('carc_info' , {
		fields: [
		        'info_seq' , 'name'
		       ,'description' , 'detail_desc'
		       ,'open_time' , 'close_time'
		       ,'grade_total_point' , 'grade_total_count'
		       ,'lat' , 'lan'
		       ,'reg_date' , 'mod_date'
		       ,'addr_sido' , 'addr_gubun' , 'addr_dong' , 'addr'
		       ,'phone1' , 'phone2' , 'phone3'
		]
	});
};